<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

<div th:fragment="leftbar">
    <div class="zuo fl">
        <h3>
            <a href="#"><img id="img-avatar" src="../../img/tx.png" width="90px" height="90px"></a>
            <p class="clearfix"><span type="text" class="fl" style="font-size: 15px" id="usernameDouble"></span><span  class="fr"  ><a th:href="@{/front/logout}"  >[退出登录]</a></span></p>
        </h3>
        <div>
            <h4>我的交易</h4>
            <ul>
                <li><a href="cart">我的购物车</a></li>
                <li><a href="myorderq">我的订单</a></li>
                <li><a href="myprod">评价晒单</a></li>
            </ul>
            <h4>个人中心</h4>
            <ul>
                <li><a href="mygxin">我的中心</a></li>
                <li><a href="address">地址管理</a></li>
                <li><a href="release">商品发布</a></li>
            </ul>
            <h4>账户管理</h4>
            <ul>
                <li><a href="mygrxx">个人信息</a></li>
                <li><a href="remima">修改密码</a></li>
            </ul>
        </div>
    </div>
    <script>
        window.onload = function () {
            console.log("?????????")
        }
    </script>
    <script src="../../../js/jquery-3.5.1.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="../../js/jquery.cookie.js" type="text/javascript" charset="utf-8"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            // //获取cookie值
            // var str = document.cookie;
            // //将值切割成数组
            // var arr = str.split(";");
            // console.log(arr[0]);
                console.log("from code itself1")
                console.log("cookie中的avatar=" + $.cookie("photo"));
                $("#img-avatar").attr("src", $.cookie("photo"));

            $.ajax({
                url: "/getUserInfo",
                type: "GET",
                dataType: "json",
                success: function(json) {
                    if (json.state == 200) {
                        console.log("username=" + json.data.username);
                        console.log("email=" + json.data.email);
                        $("#username").val(json.data.username);
                        $("#email").val(json.data.email);
                        $("#usernameDouble").text(json.data.username)
                    } else {
                        alert("获取用户信息失败！" + json.message);
                    }
                }
            });
        });

    </script>
</div>
</body>

<!--<script src="../../js/jquery.cookie.js" type="text/javascript" charset="utf-8"></script>-->


</html>